package us.icitap.commandcenter.business.ejb;

import java.util.Date;

import javax.ejb.EJB;
import javax.ejb.Stateful;

import us.icitap.commandcenter.business.AppUser;
import us.icitap.commandcenter.business.Result;
import us.icitap.commandcenter.business.ejb.persistence.CommandCenter;

@Stateful
public class AppStatefulBean implements IAppStatefulBean{

	private AppUser user;
	
	@EJB
	IPersistenceBean persistenceBean;
	
	private int testInt = 11;
	
	public void login(){
		System.out.println(testInt);
		testInt += 1;
		
		user = new AppUser();

		user.setUsername("USER_TEST");
		user.setLoginDate(new Date());
		
		Result<CommandCenter> result = persistenceBean.findEntityById(139, CommandCenter.class);
		if(result.isSucceeded()){
			user.setCommandCenter(result.getObject());
		}
		else
			System.err.println(result.getMessage());
	}
	
	public AppUser getUser(){
		return user;
	}
}
